package com.imoresoft.magic.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.ambitor.grass.sql.dao.SuperDao;
import com.ambitor.grass.sql.dao.impl.SuperDaoImpl;
import com.imoresoft.agile.property.ProsReader;

public class LocalConnectionUtils {

	public static Connection getConnection() throws SQLException,
			ClassNotFoundException {
		String driveName = ProsReader.getString("DRIVER_NAME");
		String userName = ProsReader.getString("USERNAME");
		String password = ProsReader.getString("PASSWORD");
		String url = ProsReader.getString("CONNECT_URI");

		Class.forName(driveName);
		Connection conn = DriverManager.getConnection(url, userName, password);
		return conn;
	}

	public static void main(String[] args) throws Exception {
		Connection conn = getConnection();
		SuperDao dao = new SuperDaoImpl(conn);
		System.out.println(dao.queryList("sql_sql").toString());
	}
}
